﻿#pragma once
#include "XyNet/Common/Singleton.h"
#include "XyNetTest/Protocol/cpp/Test.service.h"

namespace XyNet
{
	class RpcServer;
}

namespace XyNetTest
{
	/// 聊天服务管理器
	class ChatServerManager : public XyNet::Singleton<ChatServerManager>
	{
	public:
		/// 初始化服务端，返回链接地址
		string initServer();

	private:
		/// 服务端
		shared_ptr<XyNet::RpcServer> _server;
	};

	//////////////////////////////////////////////////////////////////////////

	/// 服务端用户服务
	class ServerUserServiceImpl : public ServerUserService
	{
	public:
		ServerUserServiceImpl(XyNet::RpcServer* _server);

		virtual void onLogin(LoginMethod::Argument* argument) override;
		virtual void onLogout(LogoutMethod::Argument* argument) override;

	private:
		XyNet::RpcServer* _server;
	};

	//////////////////////////////////////////////////////////////////////////

	/// 服务端聊天服务
	class ServerChatServiceImpl : public ServerChatService
	{
	public:
		ServerChatServiceImpl(XyNet::RpcServer* server);

		virtual void onPublicSay(PublicSayMethod::Argument* argument) override;
		virtual void onPrivateSay(PrivateSayMethod::Argument* argument) override;

	private:
		XyNet::RpcServer* _server;
	};
}